<template>
  <div>
    <!-- 1、面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 2、卡片区域 -->
    <el-card>
      <el-table :data="rightsList" border style="width: 100%" stripe>
          <!-- 索引列 -->
          <el-table-column type="index" width="50px" label="#"></el-table-column>
          <!-- 数据源的3列 -->
          <el-table-column prop="authName" label="权限名称"></el-table-column>
          <el-table-column prop="path" label="路径"></el-table-column>
          <el-table-column label="权限等级">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.level=='0'">一级</el-tag>
              <el-tag v-if="scope.row.level=='1'" type="success">二级</el-tag>
              <el-tag v-if="scope.row.level=='2'" type="warning">三级</el-tag>
              <el-tag v-if="scope.row.level=='3'" type="danger">四级</el-tag>
            </template>
          </el-table-column>
        </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
    data( ){ 
      return {
        // 所有权限列表
        rightsList:[
          // {
          //   authName: "商品管理",
          //   id: 101,
          //   level: "0",
          //   path: "goods",
          //   pid: 0,
          // },
        ]
      }
    },
    methods: {
        // 获取所有权限列表
        async getRightsList(){
          const res = await this.$http('rights/list');
          if(res.data.meta.status!==200)  return;
          
          console.log('所有权限列表：',res.data);
          this.rightsList=res.data.data;
        } 
    },
    created(){
        this.getRightsList();
    }
}
</script>

<style scoped>
  .el-card {
    width: 100%;
    margin-top: 10px;
    box-shadow: 0px 0px 3px skyblue;
    background-color: #fff;
  }
  .el-table{
    margin-top: 15px;
    font-size: 13px;
  }
</style>